package com.xzcedu.writer_;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * @author 徐州城
 * @version 1.0
 */
public class BufferedCopy_ {
    public static void main(String[] args) throws Exception{

        //说明
        //1. BufferedReader 和 BufferedWriter 是对字符操作
        //2. 不要去操作 二进制文件[声音，视频，doc，pdf]，可能会导致文件损坏

        String srcFilePath = "e:\\ok.txt";
        String descFilePath = "e:\\okMyBrother.txt";
        String line;

        BufferedReader br = new BufferedReader(new FileReader(srcFilePath));
        BufferedWriter bw = new BufferedWriter(new FileWriter(descFilePath));

        //说明：readLine 读取一行内容，但是没有换行符
        while ((line = br.readLine()) != null) {
            //每读取一行，就写入
            bw.write(line);
            //每写入一行就 写如一个换行符
            bw.newLine();
        }

        //关闭流
        br.close();
        bw.close();
        System.out.println("拷贝成功...");
    }
}
